<?php
class RssController extends AppController {
    var $helpers = array ('Html','Form');
    var $name = 'Rss'; // riferimento alla cartella delle view
    
	var $uses = array();
	//var $feed_url = "https://freesurfspot:fr33surfsp0t@gmail.google.com/gmail/feed/atom";
    var $feed_url = "http://wordpress:9999/wordpress/?feed=rss2";

    public function beforeFilter(){
    	
		parent::beforeFilter();

    }


    public function index() {

		App::import('Xml');
		// $parsed_xml =& new Xml($this->feed_url);
		$parsed_xml = Xml::build($this->feed_url);
		// print_r($parsed_xml);die;
		// xml to array conversion
		// $this->rss_item = $parsed_xml->toArray();
		// print_r($this->rss_item['Rss']['Channel']['Item']);die;
		// $this->set('data', $this->rss_item['Rss']['Channel']['Item']);

		// print_r($parsed_xml);die;
		$this->set('data', $parsed_xml['channel']['item']);

    }
	
	function simplexml_to_array($xmlobj) {
	    $a = array();
	    foreach ($xmlobj->children() as $node) {
	        if (is_array($node))
	            $a[$node->getName()] = simplexml_to_array($node);
	        else
	            $a[$node->getName()] = (string) $node;
	    }
	    return $a;
	}

}
?>